//
//  WZGecodeSearchShare.m
//  ETong
//
//  Created by wanzhao on 15/12/8.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZGecodeSearchShare.h"

@interface WZGecodeSearchShare ()<BMKGeoCodeSearchDelegate>

@property (nonatomic, strong) BMKGeoCodeSearch *search;

@end

@implementation WZGecodeSearchShare

+ (WZGecodeSearchShare *)geoCodeSearchShareInstance
{
    static WZGecodeSearchShare *instance  = nil;
    static dispatch_once_t dispatch_onces;
    if(instance  == nil)
    {
        dispatch_once(&dispatch_onces, ^{
            
            instance = [[WZGecodeSearchShare alloc] init];
        });
    }
    return instance;

}

- (instancetype)init
{
    self = [super init];
    if (self) {
        _search = [[BMKGeoCodeSearch alloc] init];
        _search.delegate = self;
    }
    return self;
}

- (BOOL)wzGeoCode:(BMKGeoCodeSearchOption *)geoCodeOption
{
   return [self.search geoCode:geoCodeOption];
}

- (BOOL)wzReverseGeoCode:(BMKReverseGeoCodeOption *)reverseGeoCodeOption
{
    return [self.search reverseGeoCode:reverseGeoCodeOption];
}

- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
    if ([self.gecodeDelegate respondsToSelector:@selector(wzOnGetGeoCodeResult:result:errorCode:)]) {
        [self.gecodeDelegate wzOnGetGeoCodeResult:searcher result:result errorCode:error];
    }
}

- (void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
    if ([self.gecodeDelegate respondsToSelector:@selector(wzOnGetReverseGeoCodeResult:result:errorCode:)]) {
        [self.gecodeDelegate wzOnGetReverseGeoCodeResult:searcher result:result errorCode:error];
    }
}
@end
